package com.guigu.guliproduct.controller;


import com.guigu.gulicommon.entity.pojo.res.Res;
import com.guigu.guliproduct.service.ISkuSaleAttrValueService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

import static com.guigu.gulicommon.constant.CheckParametersConstant.SKU_ID_CANNOT_BE_NULL;

/**
 * <p>
 * sku销售属性&值 前端控制器
 * </p>
 *
 * @author 陈俊杰
 * @since 2024-07-13
 */
@RestController
@RequestMapping("/sku-sale-attr-value")
@Log4j2
public class SkuSaleAttrValueController {
    @Autowired
    private ISkuSaleAttrValueService iSkuSaleAttrValueService;

    /**
     * 根据SkuId获取销售属性组合
     *
     * @param skuId skuId
     * @return spu销售属性组合
     */
    @GetMapping("/attr-list")
    public Res<String> getAttrsListBySkuId(
            @NotNull(message = SKU_ID_CANNOT_BE_NULL)
            Long skuId
    ) {
        log.info("根据SkuId获取销售属性组合参数:[{}]", skuId);
        return iSkuSaleAttrValueService.getAttrsListBySkuId(skuId);
    }
}
